#!/usr/bin/env python3

# http://www.upriss.org.uk/python/session4.html

##    3.3) Counting hits: Modify the program again. This time the program
##    continues even after the correct number was guessed but it counts how
##    often the correct number was guessed. You'll need two counters: one
##    for the while loop and another one for the number of correct guesses.
##    After the while loop is finished, use an if statement to print either
##    "You guessed the number ... times" or "The number was not guessed at
##    all".
##
##    Note: This strategy is used in search engines: search engines display
##    each match but keep searching until they are through with the document
##    collection.

number = -1
answer = "yes"
lucky_number = 24
counter = 5
meervoud = "en"

while (number != lucky_number or answer != "stop") and counter >= 1:
    if counter == 1:
        meervoud = ""
    print("Nog {} beurt{}.".format(counter, meervoud))
    # zie http://docs.python.org/release/3.1.3/library/string.html#formatexamples
    print("Nog {c} beurt{mv}.".format(c = counter, mv = meervoud))
    counter = counter - 1
    m = input("Geef een getal of geef 'stop' om te stoppen: ")
    if (m.isdigit()):
        print("is digit: ", m)
        number = int(m)
        if number == lucky_number:
            print("lucky_number")
            break
    else:
        print("string: ", m)
        answer = m
        if answer == "stop":
            print("stop")
            break
